home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5714 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.th-darmstadt.de!news
  2. From: Enno Sandner <enno@intellektik.informatik.th-darmstadt.de>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Help! How do I reset a ifstream file-pointer to beginning?
  5. Date: Tue, 06 Feb 1996 14:01:27 +0100
  6. Organization: Fachbereich Informatik, TH Darmstadt
  7. Message-ID: <31175127.167EB0E7@intellektik.informatik.th-darmstadt.de>
  8. References: <311734E8.41C6@dlr.de>
  9. NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (X11; I; SunOS 4.1.3 sun4m)
  14.  
  15. Matthias Sodomann wrote:
  16. > Hi there,
  17. > I have a question concerning ifstream operation. I like to read a file.
  18. > It is ASCII. I got me an ifstream in; and opened the file with
  19. > in.open("filename",ios::in); So far so good. I read the whole file, and
  20. > after this I have to read it again. The reason doesn't matter! How do I
  21. > reset the file to start reading from the beginning WITHOUT closing and
  22. > reopening it? I tried to use in.seekg(0); or in.seekg(0,ios:beg); but
  23. > all this didn't help. What do I have to do? Or is this maybe a matter of
  24. > compiler? I work on a IBM RS600 AIX3.2 Workstation with the IBM C++
  25. > Compiler xlC.
  26.  
  27. You have to reset the stream-state with the 'clear' member function,
  28. e.g. add a line 'in.clear();' before you call 'in.seekg(0)'.
  29.  
  30.     Enno
  31.